var app = getApp();
var iFDU = require('../../utils/iFDU.js');
Page({

  data: {
    config: app.config,
    globalData: app.globalData,

    groupId: 0,
    title:"",
    goodsList: []
  },



  onShow: function () {
    var that = this;
    app.getUserInfo(function (globalData) {
      that.setData({
        globalData: globalData
      });

      iFDU.api.doGet(
        'product/getMainPorductList',
        {
          userId: globalData.userId,
          productGroupId: that.data.groupId
        },
        function (data) {
          that.setData({
            goodsList: data
          });
        }
      );
    });
  },

  onLoad: function (options) {
    var that = this;
    this.data.groupId = options.groupId;
    var title = options.title;
    if (title) {
      wx.setNavigationBarTitle({
        title: title
      })
    }
  },
  showGoodsDetail: function (e) {
    wx.navigateTo({
      url: '../goods-item/goods-item?goodsId=' + e.currentTarget.dataset.id,
    })
  },

  onShareAppMessage: function (res) {
    var that = this;
    return {
      title: '爱上衬衫，从「逸见」开始…',
      imageUrl: 'http://s.i-fdu.com/runto/wxa/s/yjshare.jpeg',
      path: 'pages/goods-list/goods-list?groupId=' + that.data.groupId,
      success: function (res) {
      },
      fail: function (res) {
      }
    }
  }
})